<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>
<script type="text/javascript">
var new_phone_index=2;
var new_address_index=2;
</script>

<form action="<?php echo url_for('px/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getid() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php if (!$form->getObject()->isNew()): ?>
<input type="hidden" name="sf_method" value="put" />
<?php endif; ?>
  <table>
    <tfoot>
      <tr>
        <td colspan="2">
         &nbsp;<a href="<?php echo url_for('mc/show?id='.$form->getObject()->getClientId()) ?>">Cancel</a>
          <?php if (!$form->getObject()->isNew()): ?>
            &nbsp;<?php echo link_to('Delete', 'px/delete?id='.$form->getObject()->getid(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
          <?php endif; ?>
          <input type="submit" value="Save" />
        </td>
      </tr>
    </tfoot>
    <tbody>
      <?//php echo $form ?>
    </tbody>
  </table>

	<table>

		<tfoot>
	    <tr>
	      <td colspan="2">
         &nbsp;<a href="<?php echo url_for('mc/show?id='.$form->getObject()->getClientId()) ?>">Cancel</a>
          <?php if (!$form->getObject()->isNew()): ?>
            &nbsp;<?php echo link_to('Delete', 'px/delete?id='.$form->getObject()->getid(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
          <?php endif; ?>
	        <input type="submit" value="Save" />
	      </td>
	    </tr>
	  </tfoot>



		<tr>
	    <td colspan="3">
		   	<?php echo $form['_csrf_token']; ?>
				<?php echo $form['id']; ?>
				<?php echo $form['type']; ?>		
				<?php echo $form['author']->render(); ?>
				<?php echo $form['client_id']->render(); ?>
	      <?php echo $form->renderGlobalErrors() ?>
	    </td>
	  </tr>



		<tr>
			<td colspan=3>
			<table><!--Main client Info Block -->
		      <th><?php echo $form['last_name']->renderLabel() ?>:</th>
		      <td>
		        <?php echo $form['last_name']->renderError() ?>
		        <?php echo $form['last_name'] ?>
		      </td>
					<th><?php echo $form['first_name']->renderLabel() ?>:</th>
		      <td>
		        <?php echo $form['first_name']->renderError() ?>
		        <?php echo $form['first_name'] ?>
		      </td>
		      <th><?php echo $form['middle_name']->renderLabel() ?>:</th>
		      <td>
		        <?php echo $form['middle_name']->renderError() ?>
		        <?php echo $form['middle_name'] ?>
		      </td>
		      <th><?php echo $form['px_no']->renderLabel() ?>:</th>
		      <td>
		        <?php echo $form['px_no']->renderError() ?>
		        <?php echo $form['px_no'] ?>
		      </td>

		
			</table>
			</td>
		</tr>	
		<tr>
			<td valign=top><!--Address Block column1 -->
				<fieldset>
					<legend>Address</legend>

				  <?php foreach($form['addresss'] as $formAddress): ?>
			      <?php include_partial('address', array('form'=>$formAddress)); ?>
			    <?php endforeach; ?>
					<div id="address-fieldset"></div>				
					<div class="right">
						<a href="#" onclick="jQuery.post(
							'<?php echo url_for('mc/addAddressAjax') ?>', 
							{ address_index: new_address_index },
						 function(data, textStatus) {
							jQuery('#address-fieldset').append(data); },
							'html'
							);
						new_address_index = new_address_index+1;" 
					 title="add another address">Add another Address</a>
					</div>
				</fieldset>
			</td>
			<td valign=top><!--Phone Block column2 -->
				<fieldset>
					<legend>Phone</legend>
					<!--Show the previous entered Phones. Must find a way to enclose it into a hidden div. -->
			  <?php foreach($form['phones'] as $formPhone): ?>
		      <?php include_partial('phone', array('form'=>$formPhone)); ?>
		    <?php endforeach; ?>
				<div id="phones-fieldset"></div>				
				<div class="right">
					<a href="#" onclick="jQuery.post(
						'<?php echo url_for('mc/addPhoneAjax') ?>', 
						{ phone_index: new_phone_index },
					 function(data, textStatus) {
						jQuery('#phones-fieldset').append(data); },
						'html'
						);
					new_phone_index = new_phone_index+1;" 
				 title="add another phone">Add another Phone</a>


				</div>

				</fieldset>
			</td>
			<td valign=top><!--Misc Info Block column3-->
				<table>
					<tr>
						<td>
							<fieldset>
								<legend>Email</legend>

							  <?php foreach($form['emails'] as $formEmail): ?>
						      <?php include_partial('email', array('form'=>$formEmail)); ?>
						    <?php endforeach; ?>

							</fieldset>
					</td>
					</tr>
					<tr>
						<td>
							<fieldset>
									<legend>Websites</legend>

								  <?php foreach($form['websites'] as $formWebsite): ?>
							      <?php include_partial('websites', array('form'=>$formWebsite)); ?>
							    <?php endforeach; ?>

							</fieldset>
						</td>
					</tr>

					<tr>
						<td>
						<table>
							<td>
							<fieldset>
								<legend>Social Media Accounts</legend>


						  <?php foreach($form['socialmediaaccounts'] as $formSMA): ?>
					      <?php include_partial('socialmediaaccounts', array('form'=>$formSMA)); ?>
					    <?php endforeach; ?>

							</fieldset>


			      	</td>

						</table>	
					</tr>

				</table>
			</td>
		</tr>


	</table>









</form>
